//
//  LeftCollectionCell.m
//  GBKHOME
//
//  Created by XMYY-19 on 2017/9/4.
//
//

#import "RightCollectionViewCell.h"
#import "Masonry.h"

@implementation RightCollectionViewCell
-(instancetype)initWithFrame:(CGRect)frame
{
    self = [super initWithFrame:frame];
    if (self) {
        self =[super initWithFrame:frame];
        
        self.picImage =[[UIImageView alloc] init];
        [self.contentView addSubview:self.picImage];
        
        self.nameLabel =[[UILabel alloc] init];
        [self.contentView addSubview:self.nameLabel];
        
    }
    return self;
}

-(void)setModel:(NewEquipment *)model
{
    _model = model;
    self.nameLabel.text =   model.name;
    self.nameLabel.textAlignment = NSTextAlignmentCenter;
}

-(void)setPicByName:(NSString *)name
{
    if([name isEqualToString:@"会议室"])
    {
        self.picImage.image =[UIImage imageNamed:@"huiyishi"];
    }
    else if([name isEqualToString:@"花园"])
    {
        self.picImage.image =[UIImage imageNamed:@"huayuan"];
    }
    else if([name isEqualToString:@"接待室"])
    {
        self.picImage.image =[UIImage imageNamed:@"jiedaishi"];
    }
    else if([name isEqualToString:@"前台"])
    {
        self.picImage.image = [UIImage imageNamed:@"qiantai"];
    }
}

-(UIView *)borderView{
    if (_borderView) {
        _borderView = [[UIView alloc]init];
        _borderView.layer.cornerRadius = 10.0;
        [_borderView.layer setBorderColor:[UIColor redColor].CGColor];
    }
    return _borderView;
}

-(void)layoutSubviews
{
    [super layoutSubviews];
    // __weak typeof(&*self)weakself = self;
    [_picImage mas_makeConstraints:^(MASConstraintMaker *make) {
        make.width.mas_equalTo(kFONT_SIZE_FROM_PX_VALUE(80));
        make.height.mas_equalTo(kFONT_SIZE_FROM_PX_VALUE(80));
        make.left.equalTo(self.contentView).offset(kFONT_SIZE_FROM_PX_VALUE(60));
        make.top.equalTo(self.contentView).offset(kFONT_SIZE_FROM_PX_VALUE(50));
    }];
    
    [_nameLabel mas_makeConstraints:^(MASConstraintMaker *make) {
        make.left.equalTo(self.contentView).offset(0);
        make.top.equalTo(_picImage.mas_bottom).offset(kFONT_SIZE_FROM_PX_VALUE(22));
        make.bottom.equalTo(self.contentView.mas_bottom).offset(kFONT_SIZE_FROM_PX_VALUE(-24));
        make.right.equalTo(self.contentView).offset(0);
    }];
    
    [_borderView mas_makeConstraints:^(MASConstraintMaker *make) {
        make.left.right.top.bottom.equalTo(0);
    }];
}
@end
